﻿/********************************************************************************
 * Developed by Phil Tyler (http://www.laidbackcoder.co.uk)
 * 
 * Cryptosolic is Licensed under the GNU Lesser General Public License (LGPL)
 * http://cryptosolic.codeplex.com/license
 * *****************************************************************************/
using System.Security.Cryptography;
using Cryptosolic.Security;
using Cryptosolic.Security.Hashing;

namespace Cryptosolic.Security.Encryption.Symmetric
{
	/// <summary>
	/// Advanced Encryption Standard (AES) Encryption Implementation
	/// with 256 Bit Key
	/// </summary>
	public class Aes256 : SscSymmetricAlgorithm
	{
		private IHashingAlgorithm hashAlg;
		private SymmetricAlgorithm encrtypAlg;
		
		/// <summary>
		/// Hashing Algorithm
		/// </summary>
		public override IHashingAlgorithm HashingAlg
		{
			get 
			{
				if(hashAlg == null)
				{
					hashAlg = new Hashing.Sha256();
				}
				return hashAlg;
			}
		}
		
		/// <summary>
		/// Encryption Algorithm
		/// </summary>
		internal override SymmetricAlgorithm EncryptionAlg 
		{
			get 
			{
				if(encrtypAlg == null)
				{
					encrtypAlg = new AesManaged();
				}
				return encrtypAlg;
			}
		}
		
		/// <summary>
		/// Key Size of Cipher (in bits)
		/// </summary>
		public override int KeySize
		{
			get { return 256; }
		}
		
		/// <summary>
		/// Block Size of Cipher (in bits)
		/// </summary>
		public override int BlockSize 
		{
			get { return 128; }
		}	
		
		/// <summary>
        /// Method for Padding Cipher Text
        /// </summary>
		public override BytePaddingMode Padding 
		{
			get { return BytePaddingMode.PKCS7; }
		}
		
		/// <summary>
        /// Method used for Undertaking Encryption/Decryption
        /// </summary>
		public override BlockCipherMode Mode 
		{
			get { return BlockCipherMode.CBC; }
		}
	}
}